<template>
  <div class="container">
    <IForm :formFrame="frame" labelWidth="200px" class="form-container" :formData.sync="form"></IForm>
    <div slot="action">
      <!-- <a-button class="btn" @click="cancel">取消</a-button> -->
      <a-button class="btn" type="primary" @click="submit">保存</a-button>
    </div>
    <!-- <AttrEditor :form.sync="form">
			<div slot="action">
				<a-button class="btn" @click="cancel">取消</a-button>
				<a-button class="btn" type="primary" @click="submit">提交</a-button>
			</div>
		</AttrEditor> -->

  </div>
</template>

<script>
  // import AttrEditor from "./components/AttrEditor"
  import IForm from "@/components/IForm"

  const resourceType = 'shangdai_record_list'

  export default {
    components: {
      IForm
      // AttrEditor
    },
    data() {
      return {
        uuid: '',
        form: {
          banner: []
        },
        categoryList: []
      }
    },
    computed: {
      categoryOptions() {
        return this.categoryList.map(item => {
          return {
            title: item.title,
            value: item.id
          }
        })
      },
      frame() {
        return [
          // {
          //   title: '是否开启榜单',
          //   key: 'is_need_phone',
          //   type: 'boolean',
          //   tips: '开启后，仅绑定手机号的用户可参与开盒',
          //   newline: true,
          //   required: true,
          // },
          {
            title: '是否显示榜单',
            key: 'is_show',
            type: 'boolean',
            options: [
              {
                title: '叠加显示',
                value: 'bind'
              },
              {
                title: '拆分显示',
                value: 'unbind'
              }
            ],
            // tips: '默认为叠加显示',
            newline: true,
            required: true,
            tips: '不设置则不显示'
          },
          {
            type: 'blank',
          },
          {
            title: '需显示的物品的等级',
            key: 'level_ids',
            type: 'multi_check',
            options: [
              {
                title: '等级1',
                value: 1
              },
              {
                title: '等级2',
                value: 2
              },
              {
                title: '等级3',
                value: 3
              },
              {
                title: '等级4',
                value: 4
              },
              {
                title: '等级5',
                value: 5
              },
              {
                title: '回血池',
                value: 6
              },
            ],
            tips: '此处等级依次对应奖池中的等级',
            newline: true,
            required: true,
          }
        ]
      }
    },
    created() {
      this.$http.get(`/setting/sys/${resourceType}`).then(res => {
        this.form = res.data.setting || {}
        // this.form = {
        //   a: 'b'
        // }
        // this.form.return_type = this.form.return_type || 'money'
      })
    },
    mounted() {},
    watch: {},
    methods: {
      cancel() {
        this.$router.back(-1)
      },
      submit() {
        this.$http.post(`/setting/sys/${resourceType}`, {
          setting: this.form
        }).then(res => {
          this.$message.success('保存成功')
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .form-container {
    padding-bottom: 120px;
  }

  .container {
    .btn {
      margin-right: 30px;
    }
  }
</style>
